<?php
include 'secure/core.php';
include 'user_header.php';
include 'left.php'; 
$userid = $_SESSION['userid'];
$sql = "SELECT * FROM `uploads` WHERE `uploaded_by` = '$userid'";          
$res = $ado->exec($sql);
$fetched_rows = mysql_num_rows($res);
?>
		<div id="right">
		<div class="section">
		<?php if($_GET['msg'] == '1') { ?>
		<div class="message green"><span><b>Success</b>: Your file has been successfully uploaded.</span></div>
		<?php } ?>
		<?php if($_GET['msg'] == '2') { ?>
		<div class="message red"><span><b>Error</b>: There was an error uploading your file.</span></div>
		<?php } ?>
		<?php if($_GET['msg'] == '3') { ?>
		<div class="message green"><span><b>Success</b>: You have successfully deleted your file.</span></div>
		<?php } ?>
				<div class="box">
					<div class="title">
						Manage your Files
						<span class="hide"></span>
					</div>
					<div class="content">
						<table cellspacing="0" cellpadding="0" border="0"> 
							<thead> 
								<tr>
									<th>Filename</th>
									<th>Downloads</th>
									<th>Money Earned</th>
									<th>Advanced</th>
								</tr>
							</thead>
							<tbody>
                                                       <?php 
                                                       if($fetched_rows>0){
                                                       while($row_array = mysql_fetch_assoc($res)){  ?>
							<tr>
							  <td><?php echo $row_array['file_title'];?></td>
							  <td><?php echo $files->getUsersFileDownloads($row_array['string']); ?></td>
							  <td>$<?php echo $earnings->getFileTotalEarnings($row_array['string']); ?></td>
							  <td><a href="statistics.php?file=<?php echo $row_array['string'];?>">Stats</a> | <a href="#" class="modalopen">Download Link</a>
							  <div class="modal" title="Download Link"><div class="content">The download link is: <strong><?php echo $settings->getSiteURL(); ?>download.php?file=<?php echo $row_array['string'];?></strong></div></div>  | <a href="delete.php?file=<?php echo $row_array['string'];?>">Delete</a></td>
							 </tr>
							 <?php }} else { ?>
							 <tr>
							  <td colspan="4">Currently no files uploaded</td>
							 </tr>
							 <?php } ?>
							 </tbody>
						</table>

					</div>
				</div>
			</div>
		</div>
<?php include 'footer.php'; ?>